from .control import *

class ModelListPanelListener(ModelListPanelControl):

    def __init__(self, parent=None):
        super().__init__(parent=parent)

        '''
            树控件操作
        '''
        # 树形控件事件处理
        self.Bind( wx.EVT_TREE_ITEM_RIGHT_CLICK, self.onRightTreeClick, self.treeCtrl )
        self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.onActivate, self.treeCtrl)

        self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.onItemExpanded, self.treeCtrl)
        self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.onItemCollapsed, self.treeCtrl)
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.onSelChanged, self.treeCtrl)

        # 树形控制按钮
        self.Bind(wx.EVT_BUTTON, self.onBtnRefresh, self.btnRefresh) 

        # 树形右击事件
        self.Bind(wx.EVT_MENU, self.onPopupNewApp, id=self.popup_root_new_app)
        self.Bind(wx.EVT_MENU, self.onPopupNewModel, id=self.popup_root_new_model)
        self.Bind(wx.EVT_MENU, self.onPopupDeleteModel, id=self.popup_node_delete_model)
        self.Bind(wx.EVT_MENU, self.onPopupVSCodeOpenModel, id=self.popup_node_vscode_open_model)
        self.Bind(wx.EVT_MENU, self.onPopupNodeModelMeta, id=self.popup_node_model_Meta)
        self.Bind(wx.EVT_MENU, self.onPopupNodeRFModelSerializer, id=self.popup_node_rf_ModelSerializer)

        '''
            树形-列表操作
        '''
        self.Bind(wxdv.EVT_DATAVIEW_ITEM_ACTIVATED, self.onItemDBClick, self.treeListData)
        self.Bind(wxdv.EVT_DATAVIEW_ITEM_CONTEXT_MENU, self.onItemRightClick, self.treeListData)
        self.Bind(wxdv.EVT_DATAVIEW_SELECTION_CHANGED, self.onItemSelect, self.treeListData)

        # 树形列表右击事件
        self.Bind(wx.EVT_MENU, self.onPopupTreelistAddField, self.popup_treelist_add_field)

        '''
            其它
        '''
        '''
            事件冲突，绝对是 BUG
        '''
        if not env.IsMac: # 非 Mac 监听
            self.Bind(wx.EVT_CHECKBOX, self.onCheckBoxHave, self.checkBoxHave) # 会和树形列表起冲突
        self.Bind(wx.EVT_BUTTON, self.onBtnExpandAll, self.btn_expand_all)


        '''分割面板点击事件
        '''
        self.Bind(wx.EVT_SPLITTER_DCLICK, self.onSpliterDBClick, self.splitViewsWindow)
        